package cn.net.trimmer.servlet.demo1.dao;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;

import cn.net.trimmer.servlet.demo1.entity.User;
import cn.net.trimmer.servlet.demo1.util.RowMapper;

/**
 * 用户实体类行映射
 * 
 * @author wl
 *
 */
public class UserRowMapper implements RowMapper<User> {

	@Override
	public User mapRow(ResultSet rs) {
		User user = null;
		try {
			int id = rs.getInt("id");
			String name = rs.getString("name");
			String password = rs.getString("password");
			String sex = rs.getString("sex");
			Date birthday = rs.getDate("birthday");
			user = new User(id, name, password, sex, birthday);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return user;
	}

}
